home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Demo ƒ
/
myPlatform demo ƒ
/
myPlatform.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-17
|
2KB
|
89 lines
#include "SAT.h"
/**************/
/* myPlatform demo*/
/**************/
/* This demo is a hack I made, testing if we can use faceless sprites to make stationary*/
/* obstacles. That worked pretty nicely, so I went on and made some moving platforms too.*/
/* Take it for what it is: a test hack that suggests one way to make this kind of games.*/
/* There are many other ways. The controls can be improved a lot, but it is a start.*/
/* Translated to C by Mike Zimmerman */
#include "myPlatform.h"
SATPatHandle thepat;
long l;
SpritePtr ignoreSp;
Point p;
void DrawInfo()
{
Rect r;
SATSetPortBackScreen();
SetRect(&r, 100, 50, 300, 100);
EraseRect(&r);
FrameRect(&r);
MoveTo(110, 70);
DrawString("\pSAT Platform demo");
MoveTo(110, 90);
DrawString("\pMove with , . and space");
SATBackChanged(&r);
}
main()
{
Rect tempRect;
SATInitToolbox();
SATConfigure(true, kLayerSort, kBackwardCollision, 32);
SATInit(0, 0, 512, 322); /* No PICTs */
/* Use a background pattern (instead of PICTs - just to demo that too) */
SATSetPortBackScreen();
thepat = SATGetPat(128);
SATPenPat(thepat);
SetRect(&tempRect, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
PaintRect(&tempRect);
CopyBits(&(gSAT.backScreen.port)->portBits, &gSAT.offScreen.port->portBits, &gSAT.offScreen.port->portRect, &gSAT.offScreen.port->portRect, srcCopy, nil);
DrawInfo();
/*Initialize all sprite units*/
InitPlayerSprite();
InitPlatform();
InitMovPlatform();
InitHMovPlatform();
/*Update the game window once more, so the pattern and what we drawn in DrawInfo are shown. */
SATRedraw();
GetMouse(&p);
ignoreSp = SATNewSprite(1, p.h, p.v, &SetupPlayerSprite);
ignoreSp = SATNewSprite(0, 50, 300, &SetupPlatform);
ignoreSp = SATNewSprite(0, 150, 200, &SetupPlatform);
ignoreSp = SATNewSprite(0, 250, 100, &SetupPlatform);
ignoreSp = SATNewSprite(0, 350, 50, &SetupPlatform);
ignoreSp = SATNewSprite(0, 350, 300, &SetupMovPlatform);
ignoreSp = SATNewSprite(0, 50, 200, &SetupMovPlatform);
ignoreSp = SATNewSprite(0, 200, 150, &SetupHMovPlatform);
HideCursor();
while (!Button())
{
l = TickCount();
SATRun(true);
while (l > TickCount() - 2L)
;
}
ShowCursor();
SATSetPortScreen();
SATSoundShutup();
}